home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-09-28 | 3.0 KB | 152 lines | [TEXT/MPS ] |
- /*
- File: MenuHandler.cp
-
- Contains: xxx put contents here xxx
-
- Version: xxx put version here xxx
-
- Copyright: © 1999 by Apple Computer, Inc., all rights reserved.
-
- File Ownership:
-
- DRI: xxx put dri here xxx
-
- Other Contact: xxx put other contact here xxx
-
- Technology: xxx put technology here xxx
-
- Writers:
-
- (BWS) Brent Schorsch
-
- Change History (most recent first):
-
- <SP1> 7/1/99 BWS first checked in
- */
-
- //• ———————————————————————————————————————— Includes
-
- #include <Devices.h>
- #include <Processes.h>
- #include <ToolUtils.h>
- #include <Windows.h>
-
- #include <stdio.h>
- #include <string.h>
-
- #include "AboutBox.h"
- #include "AppShellResources.h"
- #include "EventHandler.h"
- #include "MemoryHandler.h"
- #include "MenuHandler.h"
- #include "ShellWindow.h"
-
- //• ———————————————————————————————————————— Private Definitions
- //• ———————————————————————————————————————— Private Constants
- //• ———————————————————————————————————————— Private Types
- //• ———————————————————————————————————————— Private Structs
- //• ———————————————————————————————————————— Private Variables
-
- static Boolean gMenuHandlerInited = false;
-
- //• ———————————————————————————————————————— Private Functions
- //• ———————————————————————————————————————— Public Variables
-
- //• ———————————————————— MenuInit
-
- void
- MenuInit(void)
- {
- Handle theMenuBar;
-
- //• Load the menu bar
- theMenuBar = GetNewMBar(kMBAR_Main);
- if (theMenuBar == nil)
- ExitToShell();
-
- //• Install the menu bar
- SetMenuBar(theMenuBar);
-
- //• Add Apple Menu items
- AppendResMenu(GetMenuHandle(kMENU_Apple), 'DRVR');
- DisposeHandleZ(&theMenuBar);
-
- DrawMenuBar();
-
- gMenuHandlerInited = true;
- }
-
- //• ———————————————————— MenuPrepForSelect
-
- void
- MenuPrepForSelect(void)
- {
- DrawMenuBar();
- }
-
- //• ———————————————————— MenuDoChoice
-
- Boolean
- MenuDispatch(SInt32 inMenu, const short inModifiers)
- {
- SInt16 theMenu;
- SInt16 theItem;
- UInt32 menuCommand;
- MenuHandle theMenuHandle;
- Boolean handled = true;
- WindowPtr whichWindow;
- ShellWindow *myWindow = nil;
-
- if (false == gMenuHandlerInited)
- return (false);
-
- theMenu = HiWord(inMenu);
- theItem = LoWord(inMenu);
- theMenuHandle = GetMenuHandle(theMenu);
-
- //• Small hackish thing because the menu command stuff doesn't
- //• bother mentioning that you got a desk accessory.
- if ((kMENU_Apple == theMenu) && (theItem > 2))
- {
- Str255 daName;
- GrafPtr oldPort;
-
- GetPort(&oldPort);
- GetMenuItemText(theMenuHandle, theItem, daName);
- OpenDeskAcc(daName);
- SetPort(oldPort);
- }
- else
- {
- GetMenuItemCommandID(theMenuHandle, theItem, &menuCommand);
-
- whichWindow = FrontWindow();
- if (userKind == GetWindowKind(whichWindow))
- myWindow = (ShellWindow *) GetWRefCon(whichWindow);
-
- if (nil != myWindow)
- handled = (myWindow->Menu(menuCommand, inModifiers));
-
- if (!handled)
- switch (menuCommand)
- {
- case kMenuCMD_AboutBox:
- AboutBox();
- break;
-
- case kMenuCMD_Quit:
- gDone = true;
- break;
-
- default:
- handled = false;
- break;
- }
- }
-
- HiliteMenu(0);
- DrawMenuBar();
-
- return (handled);
- }
-